<template>
    <a href="javascript:;" class="totop" v-show="isShow" @click="toTop">
        <img src="../assets/images/an_zd.png" alt="">
    </a>
</template>
<script type="es6">
    export default{
        data(){
            return {
                isShow: false
            }
        },
        methods: {
            toTop(){
                $("html,body").animate({"scrollTop" : 0}, 500)
            }
        },
        mounted: function () {
            this.$nextTick(function () {
                var that = this
                $(window).on("scroll", function(){
                    var scrollTop = document.documentElement.scrollTop || document.body.scrollTop
                    if(scrollTop > 1){
                        that.isShow = true
                    }else{
                        that.isShow = false
                    }
                })
            })
        }
    }
</script>
<style scoped>
    .totop {
        width: 108px;
        height: 109px;
        display: block;
        text-align: center;
        line-height: 40px;
        position: fixed;
        bottom: 30px;
        right: 45px;
        z-index:10000;
    }
    .totop img{
        width: 100%;
        height: 100%;
    }
</style>